/**
 * @param {number[]} nums
 * @return {number[]}
 */
var countSmaller = function (nums) {
  let res = []
  for (let i = nums.length - 1; i >= 0; i--) {
    let count = 0
    for (let j = nums.length - 1; j > i; j--) {
      if (nums[j] < nums[i]) {
        count++
      }
    }
    console.log(count)
    res.unshift(count)
  }
  return res
};
console.log(countSmaller([5, 2, 6, 1]));